package com.zx.dsptuneup_TriMic.Util;

import android.text.InputFilter;
import android.text.Spanned;
import android.util.Log;
import android.widget.EditText;
import com.google.gson.Gson;
import com.zx.dsptuneup_TriMic.App;
import com.zx.dsptuneup_TriMic.Data_Bean.ChanelBean;
import com.zx.dsptuneup_TriMic.Data_Bean.DevicesDetailInfoBean;
import com.zx.dsptuneup_TriMic.Data_Bean.EqSegmentBean;
import com.zx.dsptuneup_TriMic.Enum.MessageReceiveType;
import com.zx.dsptuneup_TriMic.Tools.EventMessage;
import com.zx.dsptuneup_TriMic.Tools.NumberBaseConversionUtil;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.zx.dsptuneup_TriMic.Data_Bean.DevicesDetailInfoBean.ChannelsBean;
public class StringUtil {
    /**
     * 过滤掉常见特殊字符,常见的表情
     *
     * @param et the et
     */
    public static void setEtFilter(final EditText et) {
        InputFilter[] filters = et.getFilters();

        if (et == null) {
            return;
        }
        //表情过滤器
        InputFilter emojiFilter = new InputFilter() {
            @Override
            public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
//                final Context context = et.getContext();
//                ToastUtils.showToast(context,source.toString()+"="+dest.toString());
                try {

                    Pattern emoji = Pattern.compile(
                            "[\ud83c\udc00-\ud83c\udfff]|[\ud83d\udc00-\ud83d\udfff]|[\u2600-\u27ff]",
                            Pattern.UNICODE_CASE | Pattern.CASE_INSENSITIVE);
                    Matcher emojiMatcher = emoji.matcher(source);
                    if (emojiMatcher.find()) {
                        return "";
                    }
                    if (source.equals(" ")) {
                        return "";
                    }
                    return null;
                } catch (Exception e) {
                    return "";
                }
            }
        };
    }


    /**
     * Deal with devices info.
     * 14 + 8
     * IN(0), OUT(1)
     * 1 静音 0 关闭静音
     */
    public static void dealWithDevicesInfo(DevicesDetailInfoBean devicesDetailInfoBeans) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                List<ChannelsBean> channelsList = devicesDetailInfoBeans.getChannels();
                if(channelsList.size() != 22){
                    return;
                }
                List<ChannelsBean> inputList = channelsList.subList(0,14);
                List<ChannelsBean> outputList = channelsList.subList(14,channelsList.size());

//                App.getContext().getEqData().getInputChannelArr().clear();
//                App.getContext().getEqData().getOutputChannelArr().clear();


                for (int i=0;i<inputList.size();i++){
                    ChannelsBean channelsBean = inputList.get(i);
                    List<ChannelsBean.ChannelListBean> eqArr = channelsBean.getChannelList();

                    ArrayList<EqSegmentBean> eqSegArr = new ArrayList<>();
                    for (int ii=0;ii<eqArr.size();ii++){
                        ChannelsBean.ChannelListBean channelListBean = eqArr.get(ii);

                        EqSegmentBean eqSegmentBean = new EqSegmentBean();
                        eqSegmentBean.setEqSegName(channelListBean.getFrequency()+"");
                        eqSegmentBean.setGain(channelListBean.getGain());
                        eqSegmentBean.setQvalue(channelListBean.getQ());
                        eqSegArr.add(eqSegmentBean);
//                        eqSegArr.remove(ii);
//                        eqSegArr.add(ii,eqSegmentBean);
                    }

                    ChanelBean chanelBean = new ChanelBean();
                    chanelBean.setEqSegArr(eqSegArr);
                    chanelBean.setHighCut(channelsBean.getHighCut());
                    chanelBean.setLowCut(channelsBean.getLowCut());
                    chanelBean.setVolume(channelsBean.getVolume());
                    chanelBean.setMute(channelsBean.getMute() == 1);

//                    App.getContext().getEqData().getInputChannelArr().add(chanelBean);
                    App.getContext().getEqData().getInputChannelArr().remove(i);
                    App.getContext().getEqData().getInputChannelArr().add(i,chanelBean);
                    /**
                     * 远程开关
                     * 0 关闭    1 开启
                     * */
                    if(i==8){
                        App.getContext().getEqData().setMuteXSta(channelsBean.getRemote() == 0);
                    }

                }

                for (int j=0;j<outputList.size();j++){
                    ChannelsBean channelsBean = outputList.get(j);
                    List<ChannelsBean.ChannelListBean> eqArr = channelsBean.getChannelList();

                    ArrayList<EqSegmentBean> eqSegArr = new ArrayList<>();
                    for (int jj=0;jj<eqArr.size();jj++){
                        ChannelsBean.ChannelListBean channelListBean = eqArr.get(jj);

                        EqSegmentBean eqSegmentBean = new EqSegmentBean();
                        eqSegmentBean.setEqSegName(channelListBean.getFrequency()+"");
                        eqSegmentBean.setGain(channelListBean.getGain());
                        eqSegmentBean.setQvalue(channelListBean.getQ());
                        eqSegArr.add(eqSegmentBean);
//                        eqSegArr.remove(jj);
//                        eqSegArr.add(jj,eqSegmentBean);
                    }

                    ChanelBean chanelBean = new ChanelBean();
                    chanelBean.setEqSegArr(eqSegArr);
                    chanelBean.setHighCut(channelsBean.getHighCut());
                    chanelBean.setLowCut(channelsBean.getLowCut());
                    chanelBean.setVolume(channelsBean.getVolume());
                    chanelBean.setMute(channelsBean.getMute() == 1);

//                    App.getContext().getEqData().getOutputChannelArr().add(chanelBean);
                    App.getContext().getEqData().getOutputChannelArr().remove(j);
                    App.getContext().getEqData().getOutputChannelArr().add(j,chanelBean);
                }
            }
        }).start();
    }


    /**
     * 赵工新版
     *  尾巴后面多一个字节的 "0d"--\n
     * @param msg the msg
     */
    public static void dealWithMsgReceive(String msg) {
        msg = msg.replace(" ","");
        int lenth             = msg.length();
        if(lenth<=24){
            return;
        }

        String reqHead        = msg.substring(0,8);
        String reqTail        = msg.substring(lenth-10,lenth-2);
//        String reqTail        = msg.substring(lenth-8,lenth);
        String reqFra_id      = msg.substring(16,20);
        String operation_type = msg.substring(20,22);
        String type           = msg.substring(22,24);

        //  数据
//        int tailIndex = msg.indexOf(Constants.protocolEnum.returnTail.toLowerCase());
        String data           = msg.substring(24,lenth-10);
//        String data           = msg.substring(24,lenth-8);
        int dataLenth         = data.length();

        if (!operation_type.equals(Constants.operation_typeEnum.return_device_get)){
            return;
        }
        if(!reqHead.equals(Constants.protocolEnum.head.toLowerCase()) || !reqTail.equals(Constants.protocolEnum.tail.toLowerCase()) ){
            return;
        }
        // 区分输入输出互斥 判断循环体
        if(type.equals(Constants.element_typeEnum.INPUT)){
            /**
             *   channelIndex(U8) +
             *   type(u8)+frequent(u16)+Q(float)+Gain(float) 7字节 (*15段)
             *  静音u8+音量u16+frequent(u16)+frequent(u16)+高低切状态u8 8字节
             *  00 静音关闭  按钮未选中
             *  01 静音开启  按钮选中
             *  目前存在单片机返回在末尾多4个字节的问题
             * */
            int standLenth = 2 + ((7 * 15 + 8)*2); // 标准长度
            if(dataLenth != standLenth){
                return;
            }

            int channelIndex = NumberBaseConversionUtil.SixToTen(data.substring(0,2));
            Log.e("当前输入通道","=="+channelIndex);

            data = data.substring(2,standLenth);

            ChanelBean chanelBean = App.getContext().getEqData().getInputChannelArr().get(channelIndex);
            // 设置静音
            boolean isMute = NumberBaseConversionUtil.SixToTen(data.substring(7*15*2 + 0,  7*15*2 + 2)) == 0 ? false : true;
            chanelBean.setMute(isMute);

            //  音量
            String volume = data.substring(7*15*2 + 2,  7*15*2 + 6);
            chanelBean.setVolume(NumberBaseConversionUtil.SixToDecimalTen(volume));

            //  设置高低切
            String highLowSta = data.substring(7*15*2 + 14,  7*15*2 + 16);
            /**
             * 无高低切       00
             * 高切          01
             * 低切          02
             * 高低切        03
             * */
            if(!highLowSta.equals("00")){ // 存在高低切数据
                String high = data.substring(7*15*2 + 6, 7*15*2 + 10);
                String low = data.substring(7*15*2 + 10, 7*15*2 + 14);

                int highI = NumberBaseConversionUtil.SixToTen(high);
                int lowI = NumberBaseConversionUtil.SixToTen(low);

                chanelBean.setHighCut(highI);
                chanelBean.setLowCut(lowI);
            }else {
                chanelBean.setHighCut(20000);
                chanelBean.setLowCut(20);
            }

            ArrayList<EqSegmentBean> eqSegArr = chanelBean.getEqSegArr();
            for (int k=0;k<eqSegArr.size();k++) {
                EqSegmentBean eqSegmentBean = eqSegArr.get(k);

                //  设置每一段EQ数据
                String eqSegStr = data.substring(7*k*2, 7*(k+1)*2);  // 每一段eq的字符串
//                    String eqType = eqSegStr.substring(0,2);
                String frequent = eqSegStr.substring(2,6);
                String Q = eqSegStr.substring(6,10);
                String Gain = eqSegStr.substring(10,14);

                eqSegmentBean.setEqSegName(NumberBaseConversionUtil.SixToTen(frequent)+"");
                eqSegmentBean.setQvalue(NumberBaseConversionUtil.SixToDecimalTen(Q));
                eqSegmentBean.setGain(NumberBaseConversionUtil.SixToDecimalTen(Gain));

                eqSegArr.remove(k);
                eqSegArr.add(k,eqSegmentBean);
            }
            chanelBean.setEqSegArr(eqSegArr);
            App.getContext().getEqData().getInputChannelArr().remove(channelIndex);
            App.getContext().getEqData().getInputChannelArr().add(channelIndex,chanelBean);

            //  发送互斥事件
            EventMessage eventMessage = new EventMessage(MessageReceiveType.MessageRecInput, "");
            EventBus.getDefault().postSticky(eventMessage);

            String jsonStr = new Gson().toJson(chanelBean);
            Log.e("输入",jsonStr);

        }else if(type.equals(Constants.element_typeEnum.OUTPUT)){   //  输出
            int standLenth = 2 + ((7 * 10 + 3)*2); // 标准长度
            if(dataLenth != standLenth){
                return;
            }

            int channelIndex = NumberBaseConversionUtil.SixToTen(data.substring(0,2));
            Log.e("当前输出通道","=="+channelIndex);
            data = data.substring(2,standLenth);

            ChanelBean chanelBean = App.getContext().getEqData().getOutputChannelArr().get(channelIndex);

            // 设置静音
            boolean isMute = NumberBaseConversionUtil.SixToTen(data.substring(7*10*2 + 0,  7*10*2 + 2)) == 0 ? false : true;
            chanelBean.setMute(isMute);

            //  音量
            String volume = data.substring(7*10*2 + 2,  7*10*2 + 6);
            chanelBean.setVolume(NumberBaseConversionUtil.SixToDecimalTen(volume) );

            ArrayList<EqSegmentBean> eqSegArr = chanelBean.getEqSegArr();
            for (int k=0;k<eqSegArr.size();k++) {
                EqSegmentBean eqSegmentBean = eqSegArr.get(k);

                //  设置每一段EQ数据
                String eqSegStr = data.substring(7*k*2, 7*(k+1)*2);  // 每一段eq的字符串
//                    String eqType = eqSegStr.substring(0,2);
                String frequent = eqSegStr.substring(2,6);
                String Q = eqSegStr.substring(6,10);
                String Gain = eqSegStr.substring(10,14);


                eqSegmentBean.setEqSegName(NumberBaseConversionUtil.SixToTen(frequent)+"");
                eqSegmentBean.setQvalue(NumberBaseConversionUtil.SixToDecimalTen(Q));
                eqSegmentBean.setGain(NumberBaseConversionUtil.SixToDecimalTen(Gain));

                eqSegArr.remove(k);
                eqSegArr.add(k,eqSegmentBean);
            }
            chanelBean.setEqSegArr(eqSegArr);
            App.getContext().getEqData().getOutputChannelArr().remove(channelIndex);
            App.getContext().getEqData().getOutputChannelArr().add(channelIndex,chanelBean);

            //  发送互斥事件
            EventMessage eventMessage = new EventMessage(MessageReceiveType.MessageRecOutput, "");
            EventBus.getDefault().postSticky(eventMessage);

            String jsonStr = new Gson().toJson(chanelBean);
            Log.e("输出",jsonStr);


        }else if(type.equals(Constants.element_typeEnum.MUTEXmose)){
            if(data.length() != 4){
                return;
            }
            data = data.substring(2,4);

            App.getContext().getEqData().setMuteXSta(data.equals("00") ? true : false);

            //  发送互斥事件
            EventMessage eventMessage = new EventMessage(MessageReceiveType.MessageRecMuteX, "");
            EventBus.getDefault().postSticky(eventMessage);
        }

        Log.e("dealWithMsgReceive","reqHead=="+reqHead+"\nreqTail=="+reqTail+"\nreqFra_id=="+reqFra_id);

    }


    /**
     *   旧版
     * Instantiates a new Deal with msg receive.
     * 2e637669 0632 0000 5c25 020100c000
     */
    public static void dealWithMsgReceive1(String msg) {
        msg = msg.replace(" ","");

        int lenth             = msg.length();
        String reqHead        = msg.substring(0,8);
        String reqTail        = msg.substring(lenth-8,lenth);
        String reqFra_id      = msg.substring(16,20);
        String operation_type = msg.substring(20,22);
        String type           = msg.substring(22,24);
        //  数据
        String data           = msg.substring(24,lenth-8);
        if (!operation_type.equals(Constants.operation_typeEnum.return_device_get)){
            return;
        }
        if(!reqHead.equals(Constants.protocolEnum.head.toLowerCase()) || !reqTail.equals(Constants.protocolEnum.returnTail.toLowerCase()) ){
            return;
        }
        int channelSize = 0;
        // 区分输入输出互斥 判断循环体
        if(type.equals(Constants.element_typeEnum.INPUT)){
            /**
             *  type(u8)+frequent(u16)+Q(float)+Gain(float) 7位
             *  静音u8+音量u16+高低切状态u8+frequent(u16)+frequent(u16) 8位
             * */
            //
            ArrayList<String> stringArr = new ArrayList<>();
            //  (( 7 * 15 ) + 8 ) * 14
            //   data.lenth = ( 7 * 15 ) + 8
            int dataLenth =( 7 * 15 ) + 8;
            channelSize = 14 * 2;

            Log.e("data.length",""+data.length());
            if(data.length()%channelSize != 0) {
                return;
            }
            /**
             *  需要后面截取字符串，所以for循环里面判断条件 i<lenth-dataLenth*2
             * */
            for(int i = 0;i<lenth-dataLenth*2;i+=dataLenth*2){
                Log.e("index===",""+i);
                String channelStr = data.substring(i,i+(dataLenth*2));  // 每一段channel的值
                for (int j=0;j<App.getContext().getEqData().getInputChannelArr().size();j++) {
                    ChanelBean chanelBean = App.getContext().getEqData().getInputChannelArr().get(j);

                    //  设置高低音
                    String highLowSta = channelStr.substring(8*15*2 + 6,8*15*2 + 8);
                    if(highLowSta.equals("00")){ // 存在高低切数据
                        String high = channelStr.substring(7*15*2 + 8,7*15*2 + 10);
                        String low = channelStr.substring(7*15*2 + 12,7*15*2 + 14);

                        int highI = NumberBaseConversionUtil.SixToTen(high);
                        int lowI = NumberBaseConversionUtil.SixToTen(low);

                        chanelBean.setHighCut(highI);
                        chanelBean.setLowCut(lowI);
                    }else {
                        chanelBean.setHighCut(0);
                        chanelBean.setLowCut(0);
                    }



                    //  设置每一段EQ数据
                    String eqSegStr = channelStr.substring(2,7*2);  // 每一段eq的字符串
//                    String eqType = eqSegStr.substring(0,2);
                    String frequent = eqSegStr.substring(2,6);
                    String Q = eqSegStr.substring(6,10);
                    String Gain = eqSegStr.substring(10,14);

                    ArrayList<EqSegmentBean> eqSegArr = chanelBean.getEqSegArr();
                    for (int k=0;k<eqSegArr.size();k++) {
                        EqSegmentBean eqSegmentBean = eqSegArr.get(k);

                        eqSegmentBean.setEqSegName(NumberBaseConversionUtil.SixToTen(frequent)+"");
                        eqSegmentBean.setQvalue(NumberBaseConversionUtil.SixToDecimalTen(Q));
                        eqSegmentBean.setGain(NumberBaseConversionUtil.SixToDecimalTen(Gain));

                        eqSegArr.remove(k);
                        eqSegArr.add(k,eqSegmentBean);
                    }
                    chanelBean.setEqSegArr(eqSegArr);
                    App.getContext().getEqData().getInputChannelArr().remove(j);
                    App.getContext().getEqData().getInputChannelArr().add(j,chanelBean);
                }
            }

            //  发送事件
            EventMessage eventMessage = new EventMessage(MessageReceiveType.MessageRecInput, "");
            EventBus.getDefault().postSticky(eventMessage);
            String json = new  Gson().toJson(App.getContext().getEqData().getInputChannelArr());
            Log.e("inputJson==",json);

        }else if(type.equals(Constants.element_typeEnum.OUTPUT)){
            /**
             *  type(u8)+frequent(u16)+Q(float)+Gain(float) 7位
             *  静音u8+音量                                  3位
             * */
            //
            ArrayList<String> stringArr = new ArrayList<>();
            //  (( 7 * 15 ) + 3 ) * 14
            //   data.lenth = ( 7 * 15 ) + 3
            int dataLenth =( 7 * 15 ) + 3;
            channelSize = 8 * 2;

            Log.e("data.length",""+data.length());
            if(data.length()%channelSize != 0) {
                return;
            }
            for(int i = 0;i<lenth-dataLenth*2;i+=dataLenth*2){
                Log.e("index===",""+i);
                String channelStr = data.substring(i,i+(dataLenth*2));  // 每一段channel的值
                for (int j=0;j<App.getContext().getEqData().getInputChannelArr().size();j++) {
                    ChanelBean chanelBean = App.getContext().getEqData().getInputChannelArr().get(j);

                    //  设置高低音
//                    String highLowSta = channelStr.substring(7*15*2 + 6,7*15*2 + 8);
//                    if(highLowSta.equals("01")){ // 存在高低切数据
//                        String high = channelStr.substring(7*15*2 + 8,7*15*2 + 10);
//                        String low = channelStr.substring(7*15*2 + 12,7*15*2 + 14);
//
//                        int highI = NumberBaseConversionUtil.SixToTen(high);
//                        int lowI = NumberBaseConversionUtil.SixToTen(low);
//
//                        chanelBean.setHighCut(highI);
//                        chanelBean.setLowCut(lowI);
//                    }else {
//                        chanelBean.setHighCut(0);
//                        chanelBean.setLowCut(0);
//                    }

                    //  设置每一段EQ数据
                    String eqSegStr = channelStr.substring(0,7*2);  // 每一段eq的字符串
//                    String eqType = eqSegStr.substring(0,2);
                    String frequent = eqSegStr.substring(2,6);
                    String Q = eqSegStr.substring(6,10);
                    String Gain = eqSegStr.substring(10,14);

                    ArrayList<EqSegmentBean> eqSegArr = chanelBean.getEqSegArr();
                    for (int k=0;k<eqSegArr.size();k++) {
                        EqSegmentBean eqSegmentBean = eqSegArr.get(k);

                        eqSegmentBean.setEqSegName(NumberBaseConversionUtil.SixToTen(frequent)+"");
                        eqSegmentBean.setQvalue(NumberBaseConversionUtil.SixToDecimalTen(Q));
                        eqSegmentBean.setGain(NumberBaseConversionUtil.SixToDecimalTen(Gain));

                        eqSegArr.remove(k);
                        eqSegArr.add(k,eqSegmentBean);
                    }
                    chanelBean.setEqSegArr(eqSegArr);
                    App.getContext().getEqData().getInputChannelArr().remove(j);
                    App.getContext().getEqData().getInputChannelArr().add(j,chanelBean);
                }
            }

            //  发送输出事件
            EventMessage eventMessage = new EventMessage(MessageReceiveType.MessageRecOutput, "");
            EventBus.getDefault().postSticky(eventMessage);
            String json = new  Gson().toJson(App.getContext().getEqData().getInputChannelArr());
            Log.e("outputson==",json);
        }else if(type.equals(Constants.element_typeEnum.MUTEXmose)){
            // 客户端开始读取服务端过来的信息 2e637669000100008eed0205 0001 2e646e0d

            if(data.length() != 4){
                return;
            }

            String muteXSta = data.substring(0,2);

            App.getContext().getEqData().setMuteXSta(muteXSta.equals("00") ?  true : false);
            //  发送互斥事件
            EventMessage eventMessage = new EventMessage(MessageReceiveType.MessageRecMuteX, ""+muteXSta);
            EventBus.getDefault().postSticky(eventMessage);
        }

        Log.e("dealWithMsgReceive","reqHead=="+reqHead+"\nreqTail=="+reqTail+"\nreqFra_id=="+reqFra_id);
    }


    /**
     * [TYPE]-[C16]-[VERSION]-[20200717]
     *  Returns: 返回类型和型号的数组
     */

    public static String[] getTypeAndVersion(String typeStr) {
        if(!typeStr.contains("-")){
            String[] arr  = new String[2];
            arr[0] = "未知类型";
            arr[1] = "未知型号";
           return arr;
        }else{
            String[] returnArr = new String[2];
            String[] arr = typeStr.split("-");
            if(arr[0].contains("TYPE") && arr[2].contains("VERSION")) {
                String type = arr[1];
                String version = arr[3];
                if (type.contains("[") && type.contains("]") ){
                    type = type.replace("[","");
                    type = type.replace("]","");
                }
                if (version.contains("[") && version.contains("]")) {
                    version = version.replace("[","");
                    version = version.replace("]","");
                }
                returnArr[0] = type;
                returnArr[1] = version;
                return returnArr;
            }else{
                String[] arr1  = new String[2];
                arr1[0] = "未知类型";
                arr1[1] = "未知型号";
                return arr1;
            }
        }
    }

    ///  EQ查询返回[ZXZN]GAIN:%x.
    /// - Parameter value: <#value description#>
    /// - Returns: <#return value description#>
     public static String[] stringToArray_gain(String value) {
        String splitStr = value;
        if(!value.contains(":")){
            return new String[0];
        }else{
            if (splitStr.contains("\r")) {
                splitStr = splitStr.replace("\r","");
            }
            if (splitStr.contains("\t")) {
                splitStr = splitStr.replace("\t", "");
            }
            if (splitStr.contains("\n")) {
                splitStr = splitStr.replace("\n", "");
            }
        }
        String dateString = splitStr.substring(splitStr.indexOf(":")+1);
        return dateString.split("[.]");
    }

    /// z字符串转数组 例：[ZXZN]ECHO:%x:%x   [ZXZN]BASS:1c:1c:0:0\r\nAT+CI
    /// - Parameter value: <#value description#>
    public static String[] stringToArray_currency(String value) {
        if(!value.contains(":")){
            return new String[0];
        }else{
            String splitStr = value;
            //  舍弃尾巴
            if (splitStr.contains("\r")) {
                String[] arr = splitStr.split("[\r]");
                if (arr.length > 0) {
                    splitStr = arr[0];
                }
            }
            // 然后取 这个位置的 之后的字符
            String dateString =  splitStr.substring(splitStr.indexOf(":")+1);
            return dateString.split("[:]");
        }

    }

    /// 静音字符串转数组 只适合类型 "[ZXZN]MUTE:0.0.0.0.0.0.0.0.0.0.0"的字符串
    /// - Parameter value: 传入的字符串 -> 返回一个Bool类型的数组
    public static boolean[] stringToArray_mute(String value) {
        if(!value.contains(":")){
            return new boolean[0];
        }else{
            String dateString = value.substring(value.indexOf(":")+1);
            String[] arr = dateString.split("[.]");
            boolean[] boolArr  = new boolean[arr.length];
            for (int i = 0; i < arr.length; i++) {
                if(arr[i].equals("0")){
                    boolArr[i] = false;
                }else {
                    boolArr[i] = true;
                }
            }
            return boolArr;
        }
    }
}
